/* 
 * File:   msg.h
 * Author: gustavo
 *
 * Created on March 29, 2012, 2:22 AM
 */

#ifndef MSG_HPP
#define	MSG_HPP

#include <stdarg.h>

#define __error( format, ... )	Msg::error(format " - (%s:%d)\n\n", ## __VA_ARGS__, __FILE__, __LINE__)
#define __warning( format, ... ) Msg::warning(format " - (%s:%d)\n\n", ## __VA_ARGS__, __FILE__, __LINE__)
#define __notice( format, ... )	Msg::notice(format " - (%s:%d)\n\n", ## __VA_ARGS__, __FILE__, __LINE__)

#define __assert( expr ) (expr)? (void)(0) : Msg::error("[%s:%d] ASSERTION FAILURE!", __FILE__, __LINE__)
#define __assert_msg( expr, msg, ... ) (expr)? (void)(0) : Msg::error("[%s:%d] " msg " ---ASSERTION FAILURE---\n", __FILE__, __LINE__, ## __VA_ARGS__)

namespace imp {

	class Msg {
	public:

		enum msg_attrib_ {
			/** Reset the text attributes */
			ATTR_RESET = 0,
			/** Enable the bright text attributes */
			ATTR_BRIGHT = 1,
			/** Enable the dim text attributes */
			ATTR_DIM = 2,
			/** Enable the blink text attributes */
			ATTR_BLINK = 3,
			/** Enable the underline text attributes */
			ATTR_UNDERLINE = 4,
			/** Enable the reverse color text attributes */
			ATTR_REVERSE = 7,
			/** Enable the hidden text attributes */
			ATTR_HIDDEN = 8,
			//ATTR_UNDEFINED           5
			//ATTR_UNDEFINED           6
		};

		enum msg_color_ {
			/** Message color text*/
			COLOR_BLACK = 0,
			COLOR_RED = 1,
			COLOR_GREEN = 2,
			COLOR_YELLOW = 3,
			COLOR_BLUE = 4,
			COLOR_MAGENTA = 5,
			COLOR_CYAN = 6,
			COLOR_GRAY = 7,
			COLOR_WHITE = 8, // as background, WHITE means default bg
		};

		typedef enum msg_attrib_ msgAttrib;
		typedef enum msg_color_ msgColor;

		static const Msg::msgColor NOTICE_COLOR = COLOR_GREEN;
		static const Msg::msgColor WARNING_COLOR = COLOR_YELLOW;
		static const Msg::msgColor ERROR_COLOR = COLOR_RED;

		static const Msg::msgColor DEFAULT_FOREGROUND = COLOR_WHITE;
		static const Msg::msgColor DEFAULT_BACKGROUND = COLOR_WHITE;

	public: // = Constructors and Destructor ===================================

		Msg();
		~Msg();

	public: // = Methods =======================================================

		static void setAttributes(msgAttrib attrib, msgColor fg, msgColor bg);
		static void reset(void);
		//		void setAttrib(msgAttrib attrib);
		//		void setFG(msgColor color);
		//		void setBG(msgColor color);


		static void endl(void);
		static void endl(int n);
		static void notice(const char * msg, ...);
		static void warning(const char * msg, ...);
		static void error(const char * msg, ...);

	};

};


#endif	/* MSG_HPP */

